﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<%@include file="/common/javascript.jsp"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>我的书架</title>
<script type="text/javascript">
    var mainform;
    var viewType = "${viewType}";
    var id = "${id}";
    
    $(function(){
        mainform=$("#mainform");
        mainform.ligerForm();
        //渲染按钮
        LG.setFormDefaultBtn(cancel,viewType=="detail" ? null : save);
    });
    
    function save(){
            LG.submitForm(mainform, function (result) {
            	if(typeof(result)=="string"){
            		result=eval("("+result+")");
            	}
                if (!result.success) {
                    LG.showError('错误:' + result.message);
                }
                else { 
                    LG.showSuccess('保存成功', function () { 
                       LG.callParent("btableList");
                    });
                }
            });
    }
    
    function cancel(){
        var win = window.parent || window;
        if(win.dialog){
        	win.dialog.close();
        }
    }

    function deleteAttach(id){
   	 var url='${ctx}/qso/stuaidcase/deleteFile?id='+id;
   	 $.post(url,null,function(data){
   		 if(data=='true'){
   			 $("#deFile").remove();
   			 $("#upFile").css("display","block");
   		 }
   	 });
   	 
    }
    
    function downloadAttach(id){
   	 var url='${ctx}/qso/stuaid/downloadFile?id='+id;
   	 window.location = url;
   	//$.post(url,null,function(data){
   		
   	//});
   	 return false;
    }
 </script>
 
</head>

<body>
	<form name="mainform" method="post" id="mainform">
		<input type="hidden" name="viewType" value="${viewType}" />
		<input type="hidden" name="id" value="${id}" />
		<table cellpadding="0" cellspacing="0" class="l-table-edit"
			style="width: 90%; margin-top: 10px; margin-left: 15px;">
			<tr>
				<td align="right" class="l-table-edit-td" style="width: 20%">附件名称:</td>
				<td align="left" class="l-table-edit-td" style="width: 30%">${command.stuAidId.name }</td>
				<td align="right" class="l-table-edit-td" style="width: 20%">上传学生:</td>
				<td align="left" class="l-table-edit-td" style="width: 30%">${command.stuId.stuName }</td>
			</tr>
			<tr>
				<td align="right" class="l-table-edit-td" style="width: 20%">附件介绍:</td>
				<td align="left" class="l-table-edit-td" style="width: 30%" colspan="3">${ command.stuAidId.intro}</td>
			</tr>
			<tr>
				<td align="right" class="l-table-edit-td" style="width: 20%">附件列表:</td>
				<td align="left" class="l-table-edit-td" style="width:80%;" colspan="3">
					<c:forEach items="${attachments}" var="attachment">
						<div id="deFile" class="l-table-edit-td">${attachment.originalName} 
						<a onclick="return downloadAttach('${attachment.id}');"	 >下载</a>
						<c:if test="${viewType!='detail'}">
						<a onclick="return deleteAttach('${attachment.id}');"	 >删除</a>
						</c:if>
						</div>
						
					</c:forEach>
				</td> 
			</tr>
		</table>
	</form>
</body>
</html>
